package edu.scau.mis.test.jdk;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * JDK动态代理
 * 要求:目标对象有接口
 */
public class DynamicProxyOfJdkHandler implements InvocationHandler {
    private Object object;
    public DynamicProxyOfJdkHandler(final Object object) {
        this.object = object;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("代理联系业主讨价还价");
        Object result = method.invoke(object, args);
        System.out.println("代理联系业主办理过户");
        return result;
    }
}
